<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <!--
    严格模式
     ● https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Strict_mode

    当前作用域开启严格模式
     ● 'use strict'
  -->
  <script>
    function fn() {
      // 当前函数开启严格模式
      'use strict'
      username = '张智琦' // 严格模式.html:18 Uncaught ReferenceError: username is not defined
      console.log(username)
    }
    age = 18
    console.log(age)
    fn()
  </script>
  <script>
    // 当前脚本开启严格模式
    'use strict'
    gender = '男'
    console.log(gender) // Uncaught ReferenceError: gender is not defined
  </script>
</body>

</html>